Skip to content

feat(php): implement BGSAVE, BGSAVE SCHEDULE, and BGSAVE CANCEL commands#237

Merged
prateek-kumar-improving merged 36 commits into
mainfrom
php/implement-bgsave-command
Jul 10, 2026
Merged

feat(php): implement BGSAVE, BGSAVE SCHEDULE, and BGSAVE CANCEL commands#237
prateek-kumar-improving merged 36 commits into
mainfrom
php/implement-bgsave-command

Conversation

@prateek-kumar-improving

@prateek-kumar-improving prateek-kumar-improving commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Summary

Implement BGSAVE, BGSAVE SCHEDULE, and BGSAVE CANCEL commands for both standalone and cluster clients, matching PHPRedis API and the implementation in other GLIDE clients (Go, Python,
Node, C#).

Issue link

This Pull Request is linked to issue (URL): #236
Related issues and pull requests:

Features / Behaviour Changes

  • Add ValkeyGlide::bgSave(?string $mode = null): bool|string for standalone client
  • Add ValkeyGlideCluster::bgSave(mixed $route, ?string $mode = null): bool|string for cluster client
  • PHPRedis compatible: Returns true on success, false on failure by default
  • With OPT_REPLY_LITERAL enabled, returns the actual status string (e.g., "Background saving started")
  • Supports three modes:
    • null (default): Initiates a background save immediately
    • "SCHEDULE": Schedules a background save
    • "CANCEL": Aborts in-progress/scheduled saves (Valkey 8.1+)

Implementation

  • execute_bgsave_command() added in valkey_glide_commands.c
  • BGSAVE_METHOD_IMPL macro added in valkey_glide_commands_common.h
  • Macro invoked for ValkeyGlide in valkey_z_php_methods.c
  • Macro invoked for ValkeyGlideCluster in valkey_glide_cluster.c
  • BgSave case added to prepare_message_args switch in valkey_glide_core_common.c
  • Added Map response type handling in process_core_string_result for cluster multi-node responses
  • Stub definitions added to valkey_glide.stub.php and valkey_glide_cluster.stub.php

Testing

  • 3 standalone tests: testBgSave, testBgSaveSchedule, testBgSaveCancel
  • 3 cluster tests with route parameter
  • BGSAVE CANCEL tests version-gated to Valkey 8.1+
  • waitForSaveNotInProgress() helper prevents test conflicts from concurrent saves
  • Verified OPT_REPLY_LITERAL returns actual string response

Checklist

Before submitting the PR make sure the following are checked:

  • This Pull Request is related to one issue.
  • Commit message has a detailed description of what changed and why.
  • Tests are added or updated.
  • CHANGELOG.md and documentation files are updated.
  • Destination branch is correct - main or release
  • Create merge commit if merging release branch into main, squash otherwise.

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
@prateek-kumar-improving prateek-kumar-improving added the php Pull requests that update php code label Jun 30, 2026
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: prateek-kumar-improving <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
@prateek-kumar-improving prateek-kumar-improving marked this pull request as ready for review July 2, 2026 16:32
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
@currantw currantw self-requested a review July 2, 2026 17:37
Comment thread valkey_glide.stub.php

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed to 215e710.

Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideTest.php
Comment thread tests/ValkeyGlideClusterTest.php
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread valkey_glide_commands.c Outdated
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread tests/ValkeyGlideTest.php
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread valkey_glide_core_common.c
Comment thread valkey_glide_core_common.c Outdated
Comment thread valkey_glide_core_common.c Outdated
Comment thread valkey_glide_core_common.c Outdated

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed to 6124361.

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
…rsively

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed to 9f9d976.

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
@Aryex Aryex self-requested a review July 6, 2026 20:23
Comment thread valkey_glide_core_common.c Outdated

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed to 4302cf1.

Comment thread tests/ValkeyGlideClusterTest.php Outdated
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed to a657785.

Comment thread valkey_glide_cluster.stub.php
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread valkey_glide_commands.c Outdated
Comment thread valkey_glide_commands.c Outdated
Comment thread valkey_glide_core_common.c Outdated
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed to 84db088. Just a couple more comments.

Comment thread valkey_glide_cluster.stub.php Outdated
Comment thread tests/ValkeyGlideClusterTest.php Outdated
Comment thread valkey_glide_core_common.c
Comment thread valkey_glide_core_common.c Outdated
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
Signed-off-by: prateek-kumar-improving <prateek.kumar@improving.com>

@currantw currantw left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Thanks for all your work on this. ✅

Signed-off-by: Prateek Kumar <prateek.kumar@improving.com>
@prateek-kumar-improving prateek-kumar-improving merged commit 8bafac6 into main Jul 10, 2026
28 of 29 checks passed
@prateek-kumar-improving prateek-kumar-improving deleted the php/implement-bgsave-command branch July 10, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

php Pull requests that update php code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants